package com.calculator.action;

import java.awt.event.ActionEvent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.calculator.service.ISCalculator;

public class CalculatorActionBean {
	/**
	 * The default <code>Log</code> instance used to write trace messages. This
	 * instance is mapped to the implementing <code>Class</code>.
	 */
	Logger LOG = LoggerFactory.getLogger(CalculatorActionBean.class);

	@Autowired
	private ISCalculator calculatorService;

	private String operator1;
	private String operator2;
	private String sign;

	private String result;

	/**
	 * Initialice action
	 */
	public void init() {
		LOG.debug("Init: " + this.getClass());

	}

	public void listenerCalculate(ActionEvent event) {
		LOG.debug("Calling service with params... ");
		LOG.debug("operator1 : " + operator1);
		LOG.debug("operator2 : " + operator2);
		LOG.debug("sign : " + sign);
		result = calculatorService.calculate(operator1, operator2, sign);
		LOG.debug("Response from service...");
		LOG.debug("result : " + result);
	}

	/**
	 * @return the operator1
	 */
	public String getOperator1() {
		return operator1;
	}

	/**
	 * @param operator1
	 *            the operator1 to set
	 */
	public void setOperator1(String operator1) {
		this.operator1 = operator1;
	}

	/**
	 * @return the operator2
	 */
	public String getOperator2() {
		return operator2;
	}

	/**
	 * @param operator2
	 *            the operator2 to set
	 */
	public void setOperator2(String operator2) {
		this.operator2 = operator2;
	}

	/**
	 * @return the sign
	 */
	public String getSign() {
		return sign;
	}

	/**
	 * @param sign
	 *            the sign to set
	 */
	public void setSign(String sign) {
		this.sign = sign;
	}

	/**
	 * @return the result
	 */
	public String getResult() {
		return result;
	}

	/**
	 * @param result
	 *            the result to set
	 */
	public void setResult(String result) {
		this.result = result;
	}

}
